﻿using System.IO;
using System.Windows;
using System.Windows.Controls;
using VupSlashLauncher.Common;

namespace VupSlashLauncher.View
{
    /// <summary>
    /// SettingViewOtherSettingView.xaml 的交互逻辑
    /// </summary>
    public partial class SettingViewOtherSettingView : UserControl
    {
        public SettingViewOtherSettingView()
        {
            InitializeComponent();
        }

        private void OpenGameDirectoryButton_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start(GlobalValues.GameDir);
        }

        private void PatchDownloadButton_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(GlobalValues.DownloadPatchUrl))
            {
                if (IMessageBox.Show("即将打开最新补丁下载链接，是否继续？", "链接跳转", "确认打开", "稍后再说"))
                    System.Diagnostics.Process.Start("https://" + GlobalValues.DownloadPatchUrl.Replace("http://", string.Empty).Replace("https://", string.Empty));
            }
            else IMessageBox.Show("没有最新版本信息呢", "提示", "好的");
        }

        private void FirstTimeNoticeButton_Click(object sender, RoutedEventArgs e)
        {
            if (IMessageBox.Show("欢迎来到Vup杀的世界！\n在这里，你可以从另一个角度体验虚拟主播带来的快乐\n用新梗给自己，给大家带来笑容吧！\n小伙伴们不要忘了点击下方按钮加入我们一起讨论哦！", "初次见面，观察者们！", "进入官网", "暂不需要"))
                System.Diagnostics.Process.Start("https://" + GlobalValues.OfficialUrl.Replace("http://", string.Empty).Replace("https://", string.Empty));
        }

        private void OfficialButton_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start("https://" + GlobalValues.OfficialUrl.Replace("http://", string.Empty).Replace("https://", string.Empty));
        }

        private void ResetConfigButton_Click(object sender, RoutedEventArgs e)
        {
            if (!IMessageBox.Show("将会删除启动器配置文件并关闭启动器(游戏本体无影响)\n该操作无法恢复，是否继续？", "警告", "取消", "继续"))
            {
                if (Directory.Exists(GlobalValues.ConfigDir)) Directory.Delete(GlobalValues.ConfigDir, true);
                Application.Current.Shutdown();
            }
        }
    }
}
